def isPrime(a)
if a == 1;return False
test = True 
k = a - 1
while k > 1:
    if not a % k:
        test = False
        break
    k -= 1 
    return test
n = input()
r = []
for i in range (len(n))
for k in range(i + 1, len(n) + 1)
a = int(n[i:k])
if isPrime(a):
    r += [a]
print(max(r) if r else 0)


               